package org.lwx.reflect.field;

import org.lwx.annotation.target.FIELD;
import org.lwx.reflect.pojo.User;

import java.lang.reflect.Field;

/**
 * @author wx-li
 * @company 希睿科技(www.xraitech.com)
 * @copyright (c) 2018 希睿科技( www.xraitech.com )Inc. All rights reserved.
 * @date 2020/10/15 11:04
 * @since JDK1.8
 */
public class FieldTest {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchFieldException {
        Class<User> aClass = (Class<User>) Class.forName("org.lwx.reflect.pojo.User");
        Field[] fields = aClass.getFields();
        Field[] declaredFields = aClass.getDeclaredFields();
//        Field name = aClass.getField("name");
        Field name1 = aClass.getDeclaredField("name");
        if (name1.isAnnotationPresent(FIELD.class)) {
            FIELD declaredAnnotation = name1.getDeclaredAnnotation(FIELD.class);
            System.out.println(declaredAnnotation.value());
        }

        System.out.println();
    }
}
